createResultProvider

abstract fun <T : Any> createResultProvider(fallback: Supplier<T>, clazz: Class<T>): ResultProvider<T>

Creates a result provider that will return values of the given type from valid config scopes matching that type.

This provider will inspect the registered config matching to the scope provided, utilizing the fallback instead if a valid scope isn't provided.

Results are cached per scope provided. The cache is cleared automatically at the end of data pack reload.

Return

ResultProvider to supply results based on passed scopes. This should be created once per use-case (static, companion object, etc), otherwise caching won't be effective.

Author

fzzyhmstrs

Since

0.5.3

Parameters

T

non-null provider type. Needs to be a type that can actually be provided by a config

fallback

Supplier<T> - supplies a fallback value if the scope provided isn't valid. This fallback will be cached against any invalid scope, and an error logged, rather than an exception being thrown.

clazz

Class<T> - class type to provide. Scopes provided can point to either a direct instance of the type, or validatedField<T>. So Boolean and ValidatedBoolean are both valid targets for a Boolean provider.


abstract fun <T : Any> createResultProvider(fallback: Supplier<T>, drillFunction: ResultProviderSupplierJava<T>): ResultProvider<T>

Creates a result provider that will return values of the given type from valid config scopes matching that type, with a custom Supplier generator instance.

This provider will inspect the registered config matching to the scope provided, utilizing the fallback instead if a valid scope isn't provided.

Results are cached per scope provided. The cache is cleared automatically at the end of data pack reload.

Return

ResultProvider to supply results based on passed scopes. This should be created once per use-case (static, companion object, etc), otherwise caching won't be effective.

Author

fzzyhmstrs

Since

0.5.3

Parameters

T

non-null provider type. Needs to be a type that can actually be provided by a config

fallback

Supplier<T> - supplies a fallback value if the scope provided isn't valid. This fallback will be cached against any invalid scope, and an error logged, rather than an exception being thrown.

drillFunction

ResultProviderSupplierJava - a custom creator of Suppliers for creating scoped results.